struct VSOutPSIn
{
	float4 Position_VSPS : SV_POSITION0;
	float2 Texcoord_VSPS : TEXCOORD0;
};
float simulateSize;
texture2D NormalTexture;
sampler2D NormalTexture_S : register(s0) = sampler_state {Texture = <NormalTexture>;};
texture2D BackgroundTexture;
sampler2D BackgroundTexture_S : register(s1) = sampler_state {Texture = <BackgroundTexture>;};

struct VSIn
{
	float3 Position_VS : POSITION0;
	float2 Texcoord_VS : TEXCOORD0;
};


VSOutPSIn mainVS(VSIn In)
{
	VSOutPSIn Out;

	Out.Position_VSPS = float4(In.Position_VS, 1);


	float2 uv = float2(In.Texcoord_VS.x, 1.0-In.Texcoord_VS.y);



	Out.Texcoord_VSPS = uv + (simulateSize * .5);






	return Out;
}


struct PSOut
{
	float4 Color_PS : SV_TARGET0;
};

PSOut mainPS(VSOutPSIn In)
{
	PSOut Out;

	float4 normal = tex2D(NormalTexture_S, In.Texcoord_VSPS);
	normal = (normal-0.5) * 2.0;

	float r = tex2D(BackgroundTexture_S, In.Texcoord_VSPS - (normal.xy * .4)).r;
	float g = tex2D(BackgroundTexture_S, In.Texcoord_VSPS - (normal.xy * .45)).g;
	float b = tex2D(BackgroundTexture_S, In.Texcoord_VSPS - (normal.xy * .5)).b;
	Out.Color_PS = float4(r, g, b, 1);

	return Out;
}

technique Simplest
{
	pass Pass0
	{
		VertexShader = compile vs_3_0 mainVS();
		PixelShader = compile ps_3_0 mainPS();
	}
}
